__author__ = 'Muscle'

import mui
import random

import traceback
import mui.CExt.muiDX as DX
import mui.InternalUse.muiResource as muiResource
import mui.InternalUse.muiconfig as muiconfig

class MUIRenderer(DX.CDXRenderer):
    def __init__(self, dxDevice):
        self.dxDevice = dxDevice
        DX.CDXRenderer.__init__(self, dxDevice)

    def DrawBitmap(self, *args):
        if (type(args[0]) is str):
            textureRes, bordW = muiResource.getTextureResource(args[0], self.dxDevice)

            if not bordW:
                newargs = (textureRes.texture, ) + args[1:]
                DX.CDXRenderer.DrawBitmap(self, *newargs)
            else:
                newargs = (textureRes.texture, bordW, args[1]) + args[3:]
                DX.CDXRenderer.DrawBorderBitmap(self, *newargs)
        else:
            DX.CDXRenderer.DrawBitmap(self, *args)


